package com.smt.ejb3.tutoria.client;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.smt.ejb3.tutoria.StatelessEjb;

public class StatelessEjbClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			InitialContext ctx = new InitialContext();

			StatelessEjb ejb = (StatelessEjb) ctx
					.lookup("StatelessEjbBean/remote");
			System.out.println(ejb.get());
			ejb.add();
			System.out.println(ejb.get());
			ejb.add();
			System.out.println(ejb.get());
			ejb.add();
			System.out.println(ejb.get());
			System.out.println("------");
			StatelessEjb ejb2 = (StatelessEjb) ctx
					.lookup("StatelessEjbBean/remote");
			System.out.println(ejb2.get());
			ejb2.add();
			System.out.println(ejb2.get());
			ejb2.add();
			System.out.println(ejb2.get());
			ejb2.add();
			System.out.println(ejb2.get());
			System.out.println("------");
			System.out.println("ejb = ejb2 ?"+ (ejb == ejb2));

		} catch (NamingException ex) {
			ex.printStackTrace();
		}
	}

}
